<?php

class SF_Vendordiscount_Block_Adminhtml_Vendordiscount_Grid extends Mage_Adminhtml_Block_Widget_Grid
{
    public function __construct()
    {
        parent::__construct();
        $this->setId('vendordiscountGrid');
        $this->setDefaultSort('id');
        $this->setDefaultDir('ASC');
        $this->setSaveParametersInSession(true);

    }
    protected function _prepareCollection()
    {
        $collection = Mage::getModel('vendordiscount/vendordiscount')->getCollection();
//        $collection->getSelect()->where('main_table.v_carrier_product = 29');
        
        $this->setCollection($collection);
        return parent::_prepareCollection();
    }
    protected function _prepareColumns()
    {
        $this->addColumn('id', array(
            'header'	=> Mage::helper('vendordiscount')->__('ID'),
            'align'		=> 'left',
            'index'		=> 'id',
        ));
        $this->addColumn('vendor_id', array(
            'header'	=> Mage::helper('vendordiscount')->__('vendor_id'),
            'align'	    => 'left',
            'index' 	=> 'vendor_id',
            'renderer'  => '',
        ));
        $this->addColumn('logistics_type', array(
            'header'    => Mage::helper('vendordiscount')->__('logistics_type'),
            'align'     => 'left',
            'index'     => 'logistics_type',
        ));
        $this->addColumn('discount', array(
            'header'    => Mage::helper('vendordiscount')->__('discount'),
            'align'     => 'left',
            'index'     => 'discount',
        ));
        $this->addColumn('action', array(
                'header'    =>  Mage::helper('vendordiscount')->__('Action'),
                'width'     => '100',
                'type'      => 'action',
                'getter'    => 'getId',
                'actions'   => array(
                    array(
                        'caption'   => Mage::helper('vendordiscount')->__('Edit'),
                        'url'       => array('base'=> '*/*/edit'),
                        'field'     => 'id'
                    )
                ),
                'filter'    => false,
                'sortable'  => false,
                'index'     => 'stores',
                'is_system' => true,
        ));
        return parent::_prepareColumns();
    }

    protected function _prepareMassaction()
    {
        $this->setMassactionIdField('id');
        $this->getMassactionBlock()->setFormFieldName('vendordiscount');

        $this->getMassactionBlock()->addItem('delete', array(
             'label'    => Mage::helper('vendordiscount')->__('Delete'),
             'url'      => $this->getUrl('*/*/massDelete'),
             'confirm'  => Mage::helper('vendordiscount')->__('Are you sure?')
        ));
        return $this;
    }

    public function getRowUrl($row)
    {
        return $this->getUrl('*/*/edit', array('id' => $row->getId()));
    }

}